package com.atjinggu.jinggumail.order.web;

import com.alipay.api.AlipayApiException;
import com.atjinggu.jinggumail.order.config.AlipayTemplate;
import com.atjinggu.jinggumail.order.service.OrderService;
import com.atjinggu.jinggumail.order.vo.PayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author jingming
 * @Type OrderPayWebController.java
 * @Desc
 * @date 2021/3/22 9:49
 */
@Controller
public class OrderPayWebController {

    @Autowired
    AlipayTemplate alipayTemplate;

    @Autowired
    OrderService orderService;


    @ResponseBody
    @RequestMapping(value = "/orderPay",produces = "text/html")
    public  String orderPay(@RequestParam("orderSn") String orderSn) throws AlipayApiException {
//        PayVo payVo = new PayVo();
//        payVo.setBody();
//        payVo.setOut_trade_no();
//        payVo.setSubject();
//        payVo.setTotal_amount();
        PayVo payVo =  orderService.getOrderPay(orderSn);
        String pay = alipayTemplate.pay(payVo);
        System.out.println(pay);
        return pay;
    }
}